import { HttpClient } from '@angular/common/http';
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { ReplaySubject } from 'rxjs';

@Component({
  selector: 'app-detail',
  templateUrl: './detail.page.html',
  styleUrls: ['./detail.page.scss'],
})
export class DetailPage implements OnInit {
  res: Result;
  constructor(private route: ActivatedRoute, private http: HttpClient) { }

  ngOnInit() {
    let lid = this.route.snapshot.params.lid;
    let url = "http://101.96.128.94:9999/data/product/details.php?lid=";
    this.http.get(url).subscribe(
      (res: Result) => {
        this.res = res;
      }
    )
  }

  transHTML(html: string) {
    return html.replace(/src="img/g, 'src="http://101.96.128.94:9999/img');
  }
}
interface Result {
  details: ResultDetail;
}
interface ResultDetail {
  category: string;
  cpu: string;
  details: string;
  disk: string;
  is_onsale: string;
  lid: string;
  lname: string;
  memory: string;
  os: string;
  picList: PicList[];
  price: string;
  promise: string;
  resolution: string;
  shelf_time: string;
  sold_count: string;
  spec: string;
  subtitle: string;
  title: string;
  video: string;
  video_memory: string;
}
interface PicList {
  laptop: string;
  lg: string;
  md: string;
  pid: string;
  sm: string;
}